<?php
function magAutoload($className) {
	$file = str_replace('_', DS, $className) . '.php';
	require_once $file;
}

spl_autoload_register('magAutoload', true, true);

define('BP', dirname(__FILE__));	// base path
define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);

// Set include path
$paths[] = BP . DS . 'code';
$paths[] = BP . DS . 'lib';

$includePath = implode(PS, $paths);
set_include_path($includePath . PS . get_include_path());

$magFileName = BP . DS . 'code' . DS . 'Mag.php';
if (!file_exists($magFileName)) {
	echo $magFileName." was not found";
	exit;
}

require_once $magFileName;
Mag::run();